package com.zzw.utils.exception;

import com.zzw.utils.error.BaseError;

/**
 * @author zzw
 * @version 1.0
 * @title AppCommonException
 * @description <>应用异常类</>
 * @datetime 2022-12-28 8:50 下午
 */
public class AppCommonException extends RuntimeException {

    private static final long serialVersionUID = -4110170116448150706L;

    /**
     * @see BaseError 及其子类
     */
    private final String errorCode;

    public AppCommonException(BaseError error) {
        super(error.getErrorMsg());
        this.errorCode = error.getCode();
    }

    public AppCommonException(BaseError error, Throwable cause) {
        super(error.getErrorMsg(), cause);
        this.errorCode = error.getCode();
    }

    public AppCommonException(String errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
    }

    public AppCommonException(BaseError error, String message) {
        super(message);
        this.errorCode = error.getCode();
    }

    public String getErrorCode() {
        return errorCode;
    }
}
